import request from '../utils/request';

export const loginApi = async (data) => {
  try {
    const response = await request.post('/api/login', data);
    return response;
  } catch (error) {
    console.error('API Error:', error);
    throw error;
  }
};

export const getUsersApi = (params) => {
  return request.get('/api/users', { params });
};

export const getDashboardStatsApi = async () => {
  try {
    const response = await request.get('/api/dashboard/stats');
    return response;
  } catch (error) {
    console.error('Dashboard API Error:', error);
    throw error;
  }
};

export const createUserApi = (data) => {
  return request.post('/api/users', data);
};

export const updateUserApi = (id, data) => {
  return request.put(`/api/users/${id}`, data);
};

export const deleteUserApi = (id) => {
  return request.delete(`/api/users/${id}`);
};
